package com.dense.kuiniu.floatcabinet.mvp.ui.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dense.kuiniu.floatcabinet.R;
import com.dense.kuiniu.floatcabinet.mvp.manager.bord.Door;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

import javax.inject.Inject;

/**
 * @author Administrator
 * @date 2020/9/29
 */
public class BoxForAdminAdapter extends BaseMultiItemQuickAdapter<Door, BaseViewHolder> {


    @Inject
    public BoxForAdminAdapter(@Nullable List<Door> data) {
        super(data);
        addItemType(1, R.layout.item_box_admin);
        addItemType(2, R.layout.item_box_full);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, Door multiItemEntity) {
        if (multiItemEntity.getItemType() == 1) {
            Door door = (Door) multiItemEntity;
            List<String> books = door.getEpc();
            baseViewHolder.setText(R.id.tv_door_number, String.valueOf(door.getDoorNumber()));
            baseViewHolder.setText(R.id.tv_book_count, "在柜:" + (books == null ? 0 : books.size()) + "本");
        }
    }

    public void setDoors(List<Door> list) {
        setNewInstance(list);
    }

}